It is legal to download, install, make games, and sell them if you purchased the software. Also, if you use original sprites and music... unless you have permission from the artists (RTP is legal if bought).
As for distributing games, it is perfectly legal to do so if you dont charge when you use other peoples work (ie: sprites). That is why RMXP is great
. As for RM2K(3), I think Enterbrain stopped supporting it a while back, so I think downloading it and distributing games is fine.