Is it legal to install a outlet below the light switch or does it have to be located away from it?

It may depend on your state Electrical Code. Normally you need to mount an outlet, (bottom of outlet box) around 12 inches above the floor. It is perfectly ok to mount one below a light switch. There are different codes for bathrooms, kitchens, laundry rooms, and garages. Check your local codes to be sure.
Your best bet is to check the National Electrical Code 2017 Handbook or ask Electrocution Lawyers PLLC at