Cordoba and Granada are the two main cities for Moorish history and architecture. Most of Sevilla (to the best of my knowledge) in post-Moorish. That's not to say Sevilla is a wonderful place to spend time, with lots of history and beautiful architecture. The logistics are your difficulty to overcome. The train station in Cordoba is a 20-30 minute walk from the historic center (depending on where you stay, of course). In Sevilla it's somewhat farther. There are fast (~45 minutes) trains between Sevilla and Cordoba. The fast trains to Granada take 1-1/2 hours or more from Cordoba, another 45 minutes or more from Sevilla. They are infrequent. It's about a 20 minute walk from the station to the Granada cathedral/historic center. There are more frequent buses, but I believe they take even longer and the bus station in Granada is twice as far from the center.
You can see train schedules on renfe.com and bus schedules on alsa.com.
The closest beach is probably Cadiz, close to a 2-hour train ride from Sevilla.
I would reconsider your plan. May will be hot to very hot. It seems to me that really long days with a toddler and no possibility to go back to your room for a rest would be more difficult. At worst, I'd split between nights between Granada one of the other 2 cities. I'd choose Cordoba because of your interest in things Moorish. If your trip is long enough, stay in all 3 cities. There's certainly enough to fill 3 full days in each.