How to save posts position on homepage after random function?

You need to change the way you’re querying for posts so that you can pass a seed value into MySQLs RAND function. If your posts are displayed within the same hour, that seed (and your post order) will remain unchanged.

This post shows an example. I’ve modified it to show how it might be done by the hour:

Try it with this in your theme functions.php file:

function hour_random_posts_orderby( $orderby ) {
    $seed = floor( time() / 3600 );
    $orderby = str_replace( 'RAND()', "RAND({$seed})", $orderby );
    return $orderby;
}

Now query for random posts like this:

<?php
$args = array(
    'orderby'        => 'rand'
);

add_filter( 'posts_orderby', 'hour_random_posts_orderby' );
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
    while ( $the_query->have_posts() ) {
        $the_query->the_post();
        ....
    }
}
else {
    echo "<p>No posts found</p>";
    ....
}
....
wp_reset_postdata();
remove_filter( 'posts_orderby', 'hour_random_posts_orderby' );
?>