How to dynamically generate wordpress editor on frontend?

You are in luck. There is a WordPress internal function for that. It’s the wp_editor function.

The function does all the work for you. It enqueues the right scripts and style-sheets. Just pass the configuration you want.

wp_editor('Enter your text here', 'editor_id_here')