The example sketches available in the IDE are available under different licenses depending on the library containing them. Learn how to find the license for a specific sketch or library below.
Check the sketch header
Often the sketch will include license information in the header comment. For example, this is the header comment for the built-in example
/* Fade This example shows how to fade an LED on pin 9 using the analogWrite() function. The analogWrite() function uses PWM, so if you want to change the pin you're using, be sure to use another PWM capable pin. On most Arduino, the PWM pins are identified with a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11. This example code is in the public domain. https://www.arduino.cc/en/Tutorial/BuiltInExamples/Fade */
Since this sketch is in the public domain, you can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.
All the built-in examples (grouped as Built-in Examples in the Example list) are available under the CC0-1.0 License by default. However, this default license is overridden by any license specific for an included library. You can view the repository here.
Check the library repository
If the example sketch does not include license information, you can check the library repository. Most of the libraries that come with the IDE by default are part of the official Arduino library repository. Many other libraries can be found in the library reference pages.