How to create a page with a form programmatically in WP?

You can use wp_insert_post() function with ‘after_theme_setup‘ action hook to programatically create pages. Here is a short example,

add_action( 'after_setup_theme', 'create_form_page' );
function create_form_page(){

    $title="Form";
    $slug = 'form';
    $page_content=""; // your page content here
    $post_type="page";

    $page_args = array(
        'post_type' => $post_type,
        'post_title' => $title,
        'post_content' => $page_content,
        'post_status' => 'publish',
        'post_author' => 1,
        'post_slug' => $slug
    );

    if(post_exists($title) === 0){
        $page_id = wp_insert_post($page_args);
    }

}