Let's say for some odd reason, a planet (while in orbit of something) travels at all times inside of a nebula. What all would happen to the planet? Could it sustain life (if sunlight was substituted), or would the nebula cause some other nasty side effects?
Like Samuel mentioned in a comment, the effects would be minor to slim at most, and probably not detectable except from a significant distance.
Nebulae are extremely sparse. Wikipedia states that
most nebulae are far less dense than any vacuum created in an Earthen environment - a nebular cloud the size of the Earth would weigh only a few kilograms.
This can be compared to the Earth's mass of nearly 6×1024 kg. If we take "a few kilograms" to be approximately equal to "6 kg", then a nebula is 10-24 times as dense as the Earth. While the numbers aren't directly comparable because of the difference in size, for comparison, the Earth weighs 3×10-6 times as much as the sun. We can also compare a planetary nebula's 102 to 104 particles per cm3 to Earth's atmosphere's some 1016/cm3. This is more than in the interstellar vacuum, but still a better vacuum than we can manage to create here on Earth with current technology (which is, at best, some 103/cm3).
I find the probability that such a sparse gas cloud would have any real measurable effect on the planet itself to be very small, although over extreme periods of time it might cause the planet's orbit around the sun to degrade ever so slightly. I would consider it more likely that the planet would just clear its path around the central star, similar to how some of Saturn's moons clear their path through Saturn's rings.
The probability that said gas cloud would have any effect at ground level on a planet that would otherwise be able to sustain life (sufficient gravity, atmosphere, etc.), even if said planet was in the middle of the nebula, seems even smaller.
The probability of any of the gas making it to the surface of a planet seems even smaller than that.
If all gas in the Earth-sized nebula described by Wikipedia was added to the Earth's atmosphere, it would result in a concentration of about 10-17, or about 10 parts per billion billion. The stuff would have to be pretty seriously nasty for that to even be detectable.
If you found yourself suspended in the midst of a nebula, you likely would never know. That is to say, if you flew your rocket ship up to, say, the Orion Nebula, it would pretty much look like nothing was there. /.../ The reason that interstellar clouds appear opaque and dense is because they are very, very, very, very far away and very, very, very, very large, and this perspective makes the clouds appear compressed and thus solid.
This interstellar particle density might plausibly make things very slightly interesting for your FTL-drive-equipped space-faring civilization, but that's probably about it.
What you should keep in mind is that nebulae are normally formed as a byproduct of stars growing old and shedding some of their mass. The probability of any planet orbiting the star that formed the nebula to support life seems miniscule at the very most, although with large nebulae, it is certainly possible that the nebula extends into other planetary systems which are able to sustain life on one or more planets orbiting the central star.
So go ahead and place your planet in the middle of a nebula if you want to, but don't expect the nebula to do anything too fancy to the planet or its inhabitants. If you want it to be realistic, make sure to place the star system in a region of space with a mixture of old and young stars within a radius of, say, 50 light years.
It depends on the density and composition, generally the first figure is so low that the composition doesn't matter at all, stellar wind also breaks up nebulae so a planetary system will usually be safe from any particles in the cloud. The only scenario I can think of in which there might be any problems would be if the planet's star system was travelling so fast that the primary didn't push the materia of an unusually high density nebula out of the orbital path of the planet and that nebula was primarily composed of something like FOOF or other extremely reactive compounds that will create a rising concentration of toxic and reactive compounds in turn.