You will need a function to get all the published posts and count the words.
function wpse410818_count_published_words() {
$posts = new WP_Query(array(
'post_type' => array( 'post' ),
'post_status' => 'publish',
));
$count = 0; //Starting words count
if ( $posts->have_posts() ) {
while ( $posts->have_posts() ) {
$posts->the_post();
//Add to the word count
$count += str_word_count(trim(strip_tags(strip_shortcodes(get_the_content()))));
}
}
echo $count;
}
This will query the database everytime it runs, therefor, you might want to cache the result and update it when a new post is published or an existing post is modified.