Yes, Kodi itself is legal. Safety depends on only installing add-ons from trusted sources.