You can move and cast.
If you attempt a ranged attack while in melee range of a hostile, you suck at it.
Concentration is a big thing; the most efficient 5e spells require it, which both means 1 up at a time, and ability for the spell to be disrupted.